archive: Prevent symlink-directory collision chmod attack (#442)
authorAlex Crichton <alex@alexcrichton.com>
Thu, 19 Mar 2026 21:58:05 +0000 (16:58 -0500)
committerFabian Grünbichler <debian@fabian.gruenbichler.email>
Wed, 8 Apr 2026 17:02:02 +0000 (19:02 +0200)
commit15004c6a33775071a11749664398de8b2e2aea99
treeeadfb93e9eeb6e209578ce3221fc4c2fb91eff5a
parent4786fc9ce690abe21a35dae785ca70ccedbbed98
archive: Prevent symlink-directory collision chmod attack (#442)

When unpacking a tarball containing a symlink followed by a directory
entry with the same path, unpack_dir previously used fs::metadata()
which follows symlinks. This allowed an attacker to modify permissions
on arbitrary directories outside the extraction path.

The fix uses fs::symlink_metadata() to detect symlinks and refuse to
treat them as valid existing directories.

Document more exhaustively+consistently security caveats.

Reported-by: Sergei Zimmerman <https://github.com/xokdvium>
Assisted-by: OpenCode (Claude claude-opus-4-5)
Signed-off-by: Colin Walters <walters@verbum.org>
Co-authored-by: Colin Walters <walters@verbum.org>
FG: drop test-related changes
Signed-off-by: Fabian Grünbichler <debian@fabian.gruenbichler.email>
Fixes: CVE-2026-33056
Gbp-Pq: Topic vendor
Gbp-Pq: Name tar-CVE-2026-33056.patch
vendor/tar-0.4.44/src/archive.rs
vendor/tar-0.4.44/src/entry.rs